<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>

<link rel="stylesheet" type="text/css" href="/META-INF/resources/static/devtools30/js/bootstrap-3.3.5/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/META-INF/resources/static/devtools30/js/jquery-easyui-1.5/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/META-INF/resources/static/devtools30/js/jquery-easyui-1.5/themes/icon.css">
<link rel="stylesheet" href="/META-INF/resources/static/devtools30/js/plugins/validationEngine/css/validationEngine.jquery.css" type="text/css"/>
<link rel="stylesheet" type="text/css" href="/META-INF/resources/static/devtools30/css/styledevtools.css">
<link rel="stylesheet" href="/META-INF/resources/static/devtools30/js/plugins/layer/skin/layer.css" />
<link rel="stylesheet" type="text/css" href="/static/portalres/jsfolder/htmlxjs/skins/dhtmlxgrid.css"/>
<link rel="stylesheet" type="text/css" href="/static/portalres/jsfolder/htmlxjs/skins/dhtmlxgrid_pgn_bricks.css"/>

<script type="text/javascript" src="/static/portalres/jsfolder/htmlxjs/dhtmlxcommon.js"></script>
<script type="text/javascript" src="/static/portalres/jsfolder/htmlxjs/dhtmlxcontainer.js"></script>
<script type="text/javascript" src="/static/portalres/jsfolder/htmlxjs/dhtmlxgrid.js"></script>
<script type="text/javascript" src="/static/portalres/jsfolder/htmlxjs/dhtmlxgridcell.js"></script>
<script type="text/javascript" src="/static/portalres/jsfolder/htmlxjs/dhtmlxgrid_filter.js"></script>
<script type="text/javascript" src="/static/portalres/jsfolder/htmlxjs/dhtmlxgrid_pgn.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/bootstrap-3.3.5/bootstrap.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/jquery-easyui-1.5/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/jquery-easyui-1.5/datagrid-filter.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/jquery-easyui-1.5/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/my97DatePicker/WdatePicker.js" ></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/plugins/layer/layer.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/easyuiPager.js?=5"></script>

<script src="/META-INF/resources/static/devtools30/js/plugins/validationEngine/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
<script src="/META-INF/resources/static/devtools30/js/plugins/validationEngine/languages/jquery.validationEngine-zh_CN.js" type="text/javascript" charset="utf-8">
</script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/ajaxfileupload.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/datagrid-dnd.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/FormValidation.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/commondevtools.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/jquery.cookie.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/html2canvas.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/canvas2image.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/jspdf.debug.js"></script>
<script type="text/javascript" src="/META-INF/resources/static/devtools30/js/usetools/dldevusetool.js"></script>

<style>
    /*去掉滚动条*/
    body{overflow-y:hidden;}
</style>

<body>

<div style="margin:0 5px; overflow: hidden;" id="bodyele">
    <div class="navheader form-inline" style="height:33px;margin-bottom: 0px;" id="div_navheader">
        <div class=" form-group" style="display: inline;" id="div_nhleftbutton">

        </div>
        <div class="btn-group-right">
            <div class="btn-group "  role="group">
                <button type="button" class="btn btn-default bi-btn-width90" onclick="refresh()">刷新</button>
            </div>
        </div>
    </div>
    <div style="width:100%;float:left;display:inline-block;padding-top:10px;">
        <table id="weidatagrid1" class="datagrid" ></table>

    </div>
</div>
</body>
</html>

<script>

    var jsonData1= {
        "userInfo": {
        "NICKNAME": "昵称",
            "OPENID": "openid",
            "CITY": "市",
            "OPERATE": "操作",
            "ROUTINE": "程序名",
            "GENDER": "性别",
            "PROVINCE": "省",
            "ID": "ID"
    }
    }
    // $.ajax({
    //     type: "POST",
    //     url: "https://testhbi.wxapp.dlhbi.net/WxRequest?p_dm=wx_ADRGIcd_Search&dm=123321",
    //     contentType: "application/json; charset=utf-8",
    //     data: JSON.stringify(jsonData1),
    //     // headers: {'dtuser' :''},
    //     dataType: "json",
    //     success: function (message) {
    //         if (message > 0) {
    //             alert("请求已提交！我们会尽快与您取得联系");
    //         }
    //     },
    //     error: function (message) {
    //         $("#request-process-patent").html("提交数据失败！");
    //     }
    // });


    // $.ajax({
    //     type: 'get',
    //     url: 'http://192.168.0.122:8081/devindex?rdm=' + parseInt(Math.random() * 100000),
    //     headers: {'dtuser' :$.cookie('dtuser')},
    //     xhrFields: {
    //         withCredentials: true
    //     },
    //     crossDomain: true,
    //     success: function (dataremot) {
    //       //  alert(dataremot);
    //     }
    // });
    var jsonData={
        "Table2": {
            "money": "2.3",
            "DESCSTR": "",
            "ZS": "9",
            "XS": "3.2",
            "id": "",
            "NAME": "88888888",
            "RQ": "2017-10-23 15:21:00"
        },
        "Table1": {
            "ID": "",
            "NAME": "6666666"
        }
    }
        $.ajax({
            type: "POST",
            url: "/commapiV2?p_dm=zgn-1&name=123321",
            contentType: "application/json; charset=utf-8",
            data: JSON.stringify(jsonData),
            headers: {'dtuser' :$.cookie('dtuser')},
            dataType: "json",
            success: function (message) {
                if (message > 0) {
                    alert("请求已提交！我们会尽快与您取得联系");
                }
            },
            error: function (message) {
                $("#request-process-patent").html("提交数据失败！");
            }
        });

//     $.post("/commapiV2?p_dm=zgn-1&name=123",JSON.stringify(jsonData),function(result){
// //        $("span").html(result);
//     });

function refresh(){
    $('#weidatagrid1').datagrid('toExcel', '/ExportController/excel', 'color');
}


    $('#weidatagrid1').datagrid({
        method:'get',
        rownumbers: true,
        singleSelect: true,
        height: findDimensions_height() - 50,
        autoRowHeight: false,
        pagination: true,
        idField: 'id',
        remoteSort: false,
        clientPaging:true,
        pageSize: 15,
        pageList: [10, 15, 20, 25, 30, 40, 50],
        columns:[[
            {field: 'id', title: 'ID', width:100, align: 'left', halign: 'center'},
            {field: 'name', title: 'name', width: 100, align: 'left', halign: 'center'},
            {field: 'rq', title: 'rq', width: 100, align: 'left', halign: 'center'},
            { field: 'xh', title: '序号', width: 60, align: 'left',sort:true, halign: 'center'}
        ]]
    });//.datagrid('clientPaging');

    //json返回
    var postdata = {p_dm: "zgn-1", sys_pagingfn: "1,1,9999"};
    $.ajax({
        url: "/commapiV2",
        type: "post",
        contentType: "application/x-www-form-urlencoded",
        headers: {'dtuser' :$.cookie('dtuser')},
        data: postdata,
        dataType: "json",
        success: function (data) {
            if (data.success) {
                var griddata = {};
                griddata.total = data.totalcount;
                griddata.rows = [];
               // alert(JSON.stringify(data.Table));
                $.each(data.Table, function (i, item) {
                    var newObject = jQuery.extend(true, {}, item);
                    griddata.rows.push(newObject);
                });
               //alert(JSON.stringify(griddata));
                $('#weidatagrid1').datagrid('loadData', griddata);
                // $('#weidatagrid1').datagrid('toExcel', '/ExportController/excel', 'color');
            }else{
                alert(JSON.stringify(data));
            }
        }
    });

    //依据驱动和sql返回数据列
    var jdbcconnstr="jdbc.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver\n";
    jdbcconnstr=jdbcconnstr+"jdbc.url=jdbc:sqlserver://127.0.0.1:1433;databaseName=drgsSystem\n";
    jdbcconnstr=jdbcconnstr+"jdbc.username=sa\n";
    jdbcconnstr=jdbcconnstr+"jdbc.password=123456\n";

    var postdata = {
        jdbcconnstr:jdbcconnstr,
        "driver" : "com.microsoft.sqlserver.jdbc.SQLServerDriver",
        "username" : "sa",
        "url" : "jdbc:sqlserver://127.0.0.1:1433;databaseName=drgsSystem",
        "password" : "123456",
        "sql" : "select * from TESTDEMOXML where id=#id#",
        "parameters" : [{
            "name" : "id",
            "value" : "1"
        }]
     };
    //json里面宝行=使用contentType: "application/json; charset=utf-8",
    $.ajax({
        url: "/CommonDbSqlApi",
        type: "post",
        contentType: "application/json; charset=utf-8",
        headers: {'dtuser' :$.cookie('dtuser')},
        data: JSON.stringify(postdata),
        dataType: "xml",
        success: function (data) {
                alert(data);
        }
    });


    var cntElem = $('#bodyele')[0];
    var shareContent = cntElem;//需要截图的包裹的（原生的）DOM 对象
    var width = shareContent.offsetWidth; //获取dom 宽度
    var height = shareContent.offsetHeight; //获取dom 高度
    var canvas = document.createElement("canvas"); //创建一个canvas节点
    var scale = 2; //定义任意放大倍数 支持小数
    canvas.width = width * scale; //定义canvas 宽度 * 缩放
    canvas.height = height * scale; //定义canvas高度 *缩放
    canvas.getContext("2d").scale(scale, scale); //获取context,设置scale
    var opts = {
        scale: scale, // 添加的scale 参数
        canvas: canvas, //自定义canvas
        // logging: true, //日志开关，便于查看html2canvas的内部执行流程
        width: width, //dom 原始宽度
        height: height,
        useCORS: true // 【重要】开启跨域配置
    };
    html2canvas(shareContent,opts)
        .then(function(canvas){
            var context = canvas.getContext('2d');
            // 【重要】关闭抗锯齿
            context.mozImageSmoothingEnabled = false;
            context.webkitImageSmoothingEnabled = false;
            context.msImageSmoothingEnabled = false;
            context.imageSmoothingEnabled = false;

            // 【重要】默认转化的格式为png,也可设置为其他格式
            var img = Canvas2Image.convertToPNG(canvas, canvas.width, canvas.height);

            document.body.appendChild(img);

            $(img).css({
                "width": canvas.width / 2 + "px",
                "height": canvas.height / 2 + "px",
            }).addClass('f-full');

            var doc=new jsPDF();
            doc.setFontSize(40);
            // doc.text(35,25,"Octonyan loves jsPDF");
            doc.addImage(img,'png',15,40,180,180);
            // doc.save("test.pdf")
        });
</script>